package org.csu.group4.jpetstore.service;

import org.csu.group4.jpetstore.mybatis.entity.Category;
import org.csu.group4.jpetstore.mybatis.entity.Product;
import org.csu.group4.jpetstore.persistence.ProductDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductService {

    @Autowired
    CategoryService categoryService;
    @Autowired
    ProductDAO productDAO;

    //通过category获得product
    public List<Product> getAllProductByCategory(Category category){
        return productDAO.getProductListByCategory(category.getCatId());
    }
    public Product getByProductId(String productId){
        return productDAO.getProduct(productId);
    }

    public List<Product> SearchProduct(String value){
        return productDAO.SearchProduct(value);
    }
    //新建product
    public void addProduct(Product product){
        productDAO.addProduct(product);
    }

}
